//
//  Date+Addition.swift
//  SlowTrajectory
//
//  Created by iOS-Czz on 2023/10/23.
//

import Foundation
extension Date {
    static func isDateToday(_ dateString: String, format: String = "yyyy.MM.dd") -> Bool {
            let dateFormatter = DateFormatter()
            dateFormatter.dateFormat = format
            
            if let date = dateFormatter.date(from: dateString) {
                let calendar = Calendar.current
                return calendar.isDateInToday(date)
            }
            
            return false
        }
    func toString(format: String) -> String {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = format
        return dateFormatter.string(from: self)
    }

    func toDate(time:String ,format: String) -> Date {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = format
        return dateFormatter.date(from: time)!
    }
    func toString(dateFormat: String) -> String {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = dateFormat
        return dateFormatter.string(from: self)
    }
}
